<h2>Редактирование данных организации</h2>

<ul id="menu">
	<li>
		<% if logged_in? %>
		<%= link_to "&larr; Назад к списку организаций", organizations_url %>
		<% end %>
	</li>
</ul>

<div class="test">
    <ul>
		<% @organization.errors.each do |attr, msg| %>
		<li><%= msg %></li>
		<% end %>
	</ul>
</div>
 
<% form_for :organization, @organization, :url => { :action => organization_form_action }, :html => { :multipart => true } do |f| %>
	
	<%= hidden_field_tag "organization_id", @organization.id %>
	
	<h3>Название организации</h3>
	
	<p>
		<label for="russian_title">На русском языке:</label><br />
		<%= f.text_field :russian_title%>
	</p>
			
	<p>
		<label for="foreign_title">На иностранном языке:</label><br />
		<%= f.text_field :foreign_title%>
	</p>

	<p>
		<label>Логотип:</label><br />
		<% if @organization.new_record? %>
			<% fields_for "organization[logo_attributes]", @organization.org_logo do |logo_form| %>
				<%= logo_form.file_field :uploaded_data, :size => 18 %>
			<% end %>
		<% else %>
			<% if @organization.org_logo != nil %>
				<p><%= link_to image_tag(@organization.org_logo.public_filename(:thumb)), @organization.org_logo.public_filename %></p>					
			<% end %>			
		<% end %>
	</p>

	<p>
		<label>Фотография:</label><br />
		<% if @organization.new_record? %>
			<% fields_for "organization[photo_attributes]", @organization.org_photo do |photo_form| %>
				<%= photo_form.file_field :uploaded_data, :size => 18 %>
			<% end %>
		<% else %>
			<% if @organization.org_photo != nil %>
				<p><%= link_to image_tag(@organization.org_photo.public_filename(:thumb)), @organization.org_photo.public_filename %></p>					
			<% end %>			
		<% end %>
	</p>


	<h3>География</h3>	
	<p>
		<label>Страна юридической регистрации:</label><br />
		<%= f.select("place", Country.find(:all).collect {|c| [ c.title, c.id ]}, {:selected => @organization.place.to_i, :include_blank => true}) %>
	</p>

	<p>
		<label>География деятельности:</label>		
		<div class="overflow">
		<% for country in Country.find(:all) %>
			<div>
			<%= check_box_tag "organization[country_ids][]", country.id, @organization.countries.include?(country) %>
			<%= country.title %>
			</div>
		<% end %>
		</div>
	</p>


	<h3>Деятельность</h3>	
	<p>
		<% for activity in Activity.find(:all) %>
			<div>
			<%= check_box_tag "organization[activity_ids][]", activity.id, @organization.activities.include?(activity), :onclick => "other_activity(this)" %> <%= activity.title %>
			</div>
		<% end %>
		
		<% if not @organization.other_activity.empty? %>
		<div id="other_activity">
			<%= f.text_area :other_activity, :size => "30x5" %>
		</div>
		<% else %>
		<div id="other_activity" style="display: none;">
			<%= f.text_area :other_activity, :size => "60x5" %>
		</div>
		<% end %>
	</p>
	
	<h3>Дополнительная информация</h3>
    <p>
        <%= f.text_area :misc, :size => "60x5" %>
    </p>


	<h3>Контактная информация</h3>
	
	<p>
		<label for="organization_phone">Телефон организации 1:</label><br />
		<%= f.text_field :phone%>
	</p>
	
	<p>
		<label for="organization_phone1">Телефон организации 2:</label><br />
		<%= f.text_field :phone1%>
	</p>
	
	<p>
		<label for="organization_phone2">Телефон организации 3:</label><br />
		<%= f.text_field :phone2%>
	</p>

	<p>
		<label for="organization_fax">Факс организации:</label><br />
		<%= f.text_field :fax%>
	</p>

	<p>
		<label for="organization_email">Эл. почта организации 1:</label><br />
		<%= f.text_field :email%>
	</p>
	
	<p>
		<label for="organization_email1">Эл. почта организации 2:</label><br />
		<%= f.text_field :email1%>
	</p>
	
	<p>
		<label for="organization_email2">Эл. почта организации 3:</label><br />
		<%= f.text_field :email2%>
	</p>
	
	<p>
		<label for="organization_icq">ICQ:</label><br />
		<%= f.text_field :icq%>
	</p>
	
	<p>
		<label for="organization_skype">Skype:</label><br />
		<%= f.text_field :skype%>
	</p>

	<p>
		<label for="organization_url">Сайт организации:</label><br />
		<%= f.text_field :url%>
	</p>
	
	<p>
		<label for="russian_post_address">Почтовый адрес на русском языке:</label><br />
		<%= f.text_field :russian_post_address, :size => 60 %>
	</p>
	
	<p>
		<label for="foreign_post_address">Почтовый адрес на иностранном языке:</label><br />
		<%= f.text_field :foreign_post_address, :size => 60 %>
	</p>

	<h3>Руководство</h3>
	<% for person in @organization.people %>
		<% fields_for "organization[person_attributes][]", person do |person_form| %>
			<p>
				<label>Фамилия:</label><br />
				<%= person_form.text_field :lastname, :index => nil %>
			</p>
			<p>
				<label>Имя:</label><br />
				<%= person_form.text_field :firstname, :index => nil %>
			</p>
			<p>
				<label>Отчество:</label><br />
				<%= person_form.text_field :middlename, :index => nil %>
			</p>
			<p>
				<label>Должность:</label><br />
				<%= person_form.text_field :post, :index => nil, :size => 70 %>
			</p>
			<p>
			    <label>Руководство?</label>
			    <%= person_form.check_box :is_main, :index => nil %>
			</p>
			<% unless person.new_record? %>
				<%= person_form.hidden_field :id, :index => nil %>
			<% end %>
		<% end %>
		<br />
	<% end %>

	<%= submit_tag submit_button_title %>
<% end %>